using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

/**
*@file       PosSyncSender.cs
*@brief      send message PosSync
*
*@author     graywind
*@version    1.0.0.1
*@data       2012/3/16
*/

//send message PosSync
public class msgPosSync
{
    public const int MessageId = (int)NetMessageTypes.MessageType.PosSync;
    //TODO
    public int SessionId = NetLib.INVALID_SESSION;
	public int GateCode = GlobalDef.INVALID_GATE_CODE;
    public possync.PosSyncMain MainMsg = new possync.PosSyncMain();
	/// <summary>
	/// Initializes a new instance of the <see cref="msgPosSync"/> class.
	/// </summary>
	/// <param name='session_id'>
	/// Session_id.
	/// </param>
	/// <param name='gate_code'>
	/// Gate_code.
	/// </param>
	/// <param name='sub_id'>
	/// Sub_id.
	/// </param>
	/// <param name='buffer'>
	/// Buffer.
	/// </param>
    public msgPosSync(int session_id, int gate_code, int sub_id, byte[] buffer)
	{
		SessionId = session_id;
		GateCode = gate_code;
		MainMsg.SubId = sub_id;
		MainMsg.SubBuffer = buffer;
	}
}

//handle message
public partial class gwMessagePort
{
    /// <summary>
    /// handle message
    /// </summary>
    /// <param name="msg">message wrapper of PosSync</param>
    public static void ProcessMessage(msgPosSync msg)
    {
        //TODO
        msgPosSyncTransfer trans = new msgPosSyncTransfer(msg.SessionId, msg.GateCode, ProtoNet<possync.PosSyncMain>.IntoBytes(msg.MainMsg));
        gwMessagePort.ProcessMessage(trans);
    }
}
